﻿using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Services;
using Microsoft.Practices.Prism.Regions;

namespace System.Architecture
{
    public abstract class NavigationAwareViewModel : ViewModelBase, INavigationAware
    {
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            Log.LogFormat(LogSeverity.Verbose, this.GetType().ToString(), "OnNavigatedTo {0}", navigationContext.ToString());
            Load();
        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            Log.LogFormat(LogSeverity.Verbose, this.GetType().ToString(), "IsNavigationTarget {0}", navigationContext.ToString());
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            Log.LogFormat(LogSeverity.Verbose, this.GetType().ToString(), "OnNavigatedFrom {0}", navigationContext.ToString());
            Save();
        }
    }

}
